<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>菱形图片</title>
    <link rel="stylesheet" href="../public.css">
    <style>
        .box {
            width: 200px;
            height: 200px;
            margin: 20px auto;
        }

        .rhombus {
            transform: rotate(45deg);
            overflow: hidden;
        }

        .rhombus img {
            max-width: 100%;
            transform: rotate(-45deg) scale(2.42);
        }

        .rhombus1 img {
            width: 200px;
            clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
        }

        .rhombus2 img {
            width:200px;
            clip-path: polygon(50% 0, 100% 50%,
                    50% 100%, 0 50%);
            transition: 1s clip-path;
        }

        .rhombus2 img:hover {
            clip-path: polygon(0 0, 100% 0,
                    100% 100%, 0 100%);
        }
    </style>
</head>

<body>
    <div class="content">
        <h1>基于变形的方案</h1>
        <ul>
            <li>将容器元素，旋转45deg，并设置overflow:hidden;</li>
            <li>将图片宽度设置为与容器对角线相等，通过scale()放大图片，在反向旋转45deg</li>
            <li>非正方形图片，容易出现问题</li>
        </ul>
        <div class="box rhombus">
            <img src="../01背景与边框/img/stone-art.jpg" alt="">
        </div>
    </div>
    <div class="content">
        <h1>裁剪路径方案</h1>
        <ul>
        </ul>
        <div class="box rhombus1">
            <img src="../01背景与边框/img/stone-art.jpg" alt="">
        </div>
        <div class="box rhombus2">
            <img src="../01背景与边框/img/stone-art.jpg" alt="">
        </div>
    </div>
</body>

</html>